package cn.com.mayue.guava.collections;

import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import org.junit.Test;

/**
 * Created by mayue on 2016/12/22.
 */
public class BiMapTest {
    @Test
    public void test() {
        //一个value只能有一个key  key value 都是唯一的
        BiMap<String, String> biMap = HashBiMap.create();
        biMap.put("1", "dog");
        //BiMap.forcePut 替换掉具有相同value的key
//        biMap.forcePut("2","dog");
        biMap.forcePut("1", "cat");

        //exp
//        biMap.put("2","dog");
        System.out.println(biMap);

        //inverse 将key value 互换
        BiMap<String, String> inverseBiMap = biMap.inverse();
        System.out.println(inverseBiMap);
    }
}
